package org.example.product.service.impl;

import org.example.product.dao.AttributeCategoryDao;
import org.example.product.service.AttributeCategoryService;
import org.example.product.vo.RelateCategoryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author 小杰_cc
 * @version 1.0
 */
@Service("categoryAttributeService")
public class AttributeCategoryServiceImpl implements AttributeCategoryService {

    @Autowired
    private AttributeCategoryDao categoryAttributeDao;

    @Override
    public void deleteByCategoryIds(List<Long> ids) {
        categoryAttributeDao.deleteByCategoryIds(ids);
    }

    @Override
    public List<RelateCategoryVo> queryCategoryListByAttrId(Long attrId) {
        return categoryAttributeDao.getCategoryListByAttrId(attrId);
    }

    // 保存分类和属性的关联关系
    @Override
    public int saveCategoryAttr(Long categoryId, Long attributeId) {
        return categoryAttributeDao.addCategoryAttr(categoryId,attributeId);
    }

    // 根据id删除关联关系
    @Override
    public int deleteAttrCategoryById(Long id) {
        return categoryAttributeDao.removeAttrCategoryById(id);
    }

    @Override
    public List<Long> queryAttrIdByCategoryId(Long categoryId) {
        return categoryAttributeDao.getAttrIdByCategoryId(categoryId);
    }

    @Override
    public void deleteByAttrIds(List<Long> ids) {
        categoryAttributeDao.deleteByAttrIds(ids);
    }

}